package com.dragon.codefx.dataBase.controller.bo;

import com.dragon.bean.SerializableDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.util.List;

/**
 * 代码生成配置类
 * @author lsc
 * @since 2024/11/30 16:38
 **/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@ApiModel("代码生成配置类")
public class GenerateBO extends SerializableDTO<GenerateBO> {
    /**
     * 数据库连接信息
     */
    @ApiModelProperty("数据库连接信息")
    private JdbcInfo jdbcInfo;

    /**
     * 配置信息
     */
    @ApiModelProperty("配置信息")
    private GenerateInfo generateInfo;


    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    @ToString
    public static class GenerateInfo {
        @ApiModelProperty("作者")
        private String author;
        @ApiModelProperty("表前缀")
        private String tablePrefix;
        @ApiModelProperty("是否生成Xml")
        private Boolean generateXml;
        @ApiModelProperty("模块路径")
        private String basePackage;
        @ApiModelProperty("表名")
        private String tableName;
        @ApiModelProperty("表描述")
        private String tableComment;
        @ApiModelProperty("数据库名")
        private String schemaName;
        @ApiModelProperty("表字段")
        List<ColumnInfo> tableColumns;
        @ApiModelProperty("父级字段")
        private List<ParentInfo> parentsField;
        @ApiModelProperty("生成方式")
        private String generateMethod;
    }

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    @ToString
    public static class ParentInfo {
        private String property;
        private String column;
    }

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    @ToString
    public static class ColumnInfo {
        @ApiModelProperty("列注释")
        private String columnComment;
        @ApiModelProperty("列名")
        private String columnName;
        @ApiModelProperty("字段类型")
        private String fieldType;
        @ApiModelProperty("前端类型")
        private String frontType;
        @ApiModelProperty("前端默认值")
        private String frontDefault;
        @ApiModelProperty("字段名")
        private String fieldName;
        @ApiModelProperty("是否主键")
        private Boolean keyFlag;
        @ApiModelProperty("是否父类字段")
        private Boolean isParent;
        @ApiModelProperty("查询条件")
        private SearchInfo searchInfo;
    }

    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    @ToString
    public static class SearchInfo {
        @ApiModelProperty("字段名")
        private String propName;
        @ApiModelProperty("查询类型")
        private String queryType;
        @ApiModelProperty("模糊查询字段")
        private String blurry;
    }


    @Getter
    @Setter
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    @ToString
    public static class JdbcInfo {
        @ApiModelProperty("数据库连接地址")
        private String url;
        @ApiModelProperty("数据库用户名")
        private String username;
        @ApiModelProperty("数据库密码")
        private String password;
    }

}
